﻿using System;
using System.Drawing;
using System.Drawing.Printing;

namespace ZYCommon
{


    public class PrintPage
    {
        private int intHeight = 0;
        private int intWidth = 0;
        private PrintPageCollection myOwnerPages = null;
        private PrinterSettings myPageSettings = null;
        public Rectangle ViewBounds = Rectangle.Empty;

        private void FixHeight()
        {
            if (this.intHeight < this.myOwnerPages.MinPageHeight)
            {
                this.intHeight = this.myOwnerPages.MinPageHeight;
            }
            if (this.intHeight > this.myOwnerPages.StandardHeight)
            {
                this.intHeight = this.myOwnerPages.StandardHeight;
            }
        }

        public int Bottom
        {
            get
            {
                return (this.Top + this.intHeight);
            }
            set
            {
                this.intHeight = value - this.Top;
                this.FixHeight();
            }
        }

        //光标缩在区域
        public Rectangle Bounds
        {
            get
            {
                return new Rectangle(0, this.Top, this.intWidth, this.intHeight);
            }
        }

        private string section_name = "";
        public string Section_name
        {
            get
            {
                return section_name;
            }
            set
            {
                pageHeadInfo.Section_name = value;
                section_name = value;
            }
        }

        private string bed_no = "";
        public string Bed_no
        {
            get
            {
                return bed_no;
            }
            set
            {
                pageHeadInfo.Bed_no = value;
                bed_no = value;
            }
        }

        private string sick_area = "";

        public string Sick_area
        {
            get { return sick_area; }
            set
            {
                pageHeadInfo.Sick_area = value;
                sick_area = value;
            }
        }

        //绘制区域
        public Rectangle ContentViewBounds
        {
            get
            {
                return new Rectangle(this.ViewBounds.X + this.myOwnerPages.LeftMargin, this.ViewBounds.Y + this.myOwnerPages.TopMargin, this.intWidth, this.intHeight);
            }
        }

        public int Height
        {
            get
            {
                return this.intHeight;
            }
            set
            {
                this.intHeight = value;
                this.FixHeight();
            }
        }

        public int Left
        {
            get
            {
                return 0;
            }
        }

        public PrintPageCollection OwnerPages
        {
            get
            {
                return this.myOwnerPages;
            }
            set
            {
                this.myOwnerPages = value;
                if (this.intHeight < this.myOwnerPages.MinPageHeight)
                {
                    this.intHeight = this.myOwnerPages.MinPageHeight;
                }
            }
        }

        public int PageIndex
        {
            get
            {
                return (this.myOwnerPages.IndexOf(this) + 1);
            }
        }

        public PrinterSettings PageSettings
        {
            get
            {
                return this.myPageSettings;
            }
            set
            {
                this.myPageSettings = value;
            }
        }

        public int Top
        {
            get
            {
                int top = this.myOwnerPages.Top;
                foreach (PrintPage page in this.myOwnerPages.Items)
                {
                    if (page == this)
                    {
                        return top;
                    }
                    top += page.Height;
                }
                return top;
            }
        }

        public int Width
        {
            get
            {
                return this.intWidth;
            }
            set
            {
                this.intWidth = value;
            }
        }

        private PageHeaders pageHeadInfo = new PageHeaders();

        public PageHeaders PageHeadInfo
        {
            get { return pageHeadInfo; }
            set
            {
                pageHeadInfo = value;
            }
        }
    }

    public class PageHeaders
    {
        private string section_name = "";
        public string Section_name
        {
            get
            {
                return section_name;
            }
            set
            {
                section_name = value;
            }
        }

        private string bed_no = "";
        public string Bed_no
        {
            get
            {
                return bed_no;
            }
            set
            {
                bed_no = value;
            }
        }

        private string sick_area = "";

        public string Sick_area
        {
            get { return sick_area; }
            set { sick_area = value; }
        }

        private string old_section_name = string.Empty;

        public string Old_section_name
        {
            get { return old_section_name; }
            set { old_section_name = value; }
        }

        private string old_bed_name = string.Empty;

        public string Old_bed_name
        {
            get { return old_bed_name; }
            set { old_bed_name = value; }
        }

        public string old_sick_area = string.Empty;

        public string Old_sick_area
        {
            get
            {
                return old_sick_area;
            }

            set
            {
                this.old_sick_area = value;
            }
        }
    }
}

